<?
/*********************************************
 *简历列表
 * *******************************************/
function smarty_function_qishi_resume_list($params, &$smarty)
{
	extract($params);
	global $db,$_CFG;
	$paged = (NULL != $paged) ? $paged : 0; //是否分页显示
	$row = (NULL != $row) ? intval($row) : 15; //默认显示记录数量
	$start  = (NULL != $start) ? intval($start): 0; //从第几条开始读取，缺省0
	$titlelen= (NULL != $titlelen) ? intval($titlelen) : 4; //默认名字截取长度
	$specialtylen = (NULL != $specialtylen) ? intval($specialtylen) : 25; //默认技能描述长度
	$dot = (NULL != $dot) ? $dot : ''; //默认截取后填补字符
	$listname = (NULL != $listname) ? $listname : "list"; //默认的section名称
	$settr = (NULL != $settr) ? $settr : ""; //时间范围
	//排列字段
	$orderby=ereg('refreshtime|addtime|id',$orderby)?$orderby:"refreshtime";
	//显示顺序
	$displayorder=ereg('asc|desc',$displayorder)?$displayorder:"DESC";
	//sql语句
	$orderbysql=" ORDER BY ".table('resume').".".$orderby." ".$displayorder;
	//
	$joinsql='';
	if ($category||$subclass)
	{
		$joinsql=" INNER JOIN  ".table('resume_intention_jobs')." ON ".table('resume').".uid=".table('resume_intention_jobs').".uid  ";
		if ($category) $joinsql.="   AND  ".table('resume_intention_jobs').".category=".intval($category)." ";
		if ($subclass) $joinsql.="   AND  ".table('resume_intention_jobs').".subclass=".intval($subclass)." ";
	}
	$wheresql=" WHERE ".table('resume').".audit='1' AND  ".table('resume').".display='1' AND ".table('resume').".complete='1'";
	$education?$wheresql.=" AND  ".table('resume').".education='".intval($education)."' ":'';
	$experience?$wheresql.=" AND  ".table('resume').".experience='".intval($experience)."' ":'';
	$district?$wheresql.=" AND  ".table('resume').".area='".intval($district)."' ":'';
	$sex?$wheresql.=" AND  ".table('resume').".sex='".intval($sex)."' ":'';
	$wage?$wheresql.=" AND  ".table('resume').".wage='".intval($wage)."' ":'';
	$photo?$wheresql.=" AND  ".table('resume').".photo_audit='1' AND  ".table('resume').".photo_display='1'  AND  ".table('resume').".photoresume='2' ":'';
	$outdated?$wheresql.=" AND ".table('resume').".deadline>'".time()."' ":'';//只显示有效信息，
	$key=trim($key);
	!empty($key)?" AND  ".table('resume').".key like '%". mysql_like_quote($key)."%'  ":'';//关键字
	if (intval($settr))
	{
		$settr_val=strtotime("-".$settr." day");
		$wheresql.=" AND ".table('resume').".addtime > ".$settr_val;
	}
	if ($paged=="1")
	{
		require_once(QISHI_ROOT_PATH.'include/page.class.php');
		$total_sql="SELECT COUNT(DISTINCT ".table('resume').".id) AS num FROM  ".table('resume').$joinsql.$wheresql;
		$total_count=get_total($total_sql);
		$page = new page(array('total'=>$total_count, 'perpage'=>$row));
		$currenpage=$page->nowindex;
		$offset=($currenpage-1)*$row;
		if ($total_count>$row)
		{
			$smarty->assign('page',$page->show(3));//分页符
		}
	}
	$offset=$offset?$offset:0;
	$offset=$start>0?$start:$offset;
	$limit=" LIMIT ".$offset.','.$row;
	$groupby=" GROUP BY ".table('resume').".id  ";
	$result = $db->query("SELECT * FROM ".table('resume')." ".$joinsql.$wheresql.$groupby.$orderbysql.$limit);
	while($row = $db->fetch_array($result))
	{
//		$row['sex']=$row['sex']=="1"?'男':'女';
		if($row['sex']==1)$row['sex']='先生';
		if($row['sex']==2)$row['sex']='太太';
		if($row['sex']==3)$row['sex']='女士';
		if($row['sex']==4)$row['sex']='小姐';
		$row['age']=date('Y',Time())-date('Y',$row['birthday']) + ((date('m',Time())-date('m',$row['birthday'])) > 0 ? 1 : 0);
		$experience_one=get_jobs_experience_one($row['experience']);
		$education_one=get_jobs_education_one($row['education']);
		$area_one=get_jobs_area_one($row['area']);
		$row['fullname']=cut_str($row['fullname'],$titlelen,0,$dot);
		$row['experience']=$experience_one['categoryname'];
		$row['education']=$education_one['categoryname'];
		$row['area']=$area_one['categoryname'];
		$row['specialty']=cut_str($row['specialty'],$specialtylen,0,$dot);
		$row['refreshtime']=date('Y-m-d',$row['refreshtime']);
		$row['photosrc']=$_CFG['resume_photo_dir_thumb'].$row['photo'];
		$row['resume_url']=url_rewrite('resume-show',array('id0'=>$row[0]));
		$List[] = $row;
	}
	$smarty->assign($listname, $List);
	unset($List);
}
?>